<?php

namespace App\Models;

use DateTimeInterface;
use Illuminate\Database\Eloquent\Model;

class ApprovalBorrow extends Model
{
    protected $appends = ['status_text'];

    protected function serializeDate(DateTimeInterface $date)
    {
        return $date->format('Y-m-d H:i:s');
    }

    protected $guarded = ['id'];

    /**
     * 追加状态数据
     * @return string
     */
    public function getStatusTextAttribute()
    {
        $status = [
            1 => '未归还',
            2 => '逾期未还',
            3 => '已归还',
        ];

        return $status[$this->status];
    }
}
